<template>
    <a-table :columns="columns" :data-source="data" rowKey="id" :pagination="false">
        <template #headerCell="{ column }">
            <template v-if="column.key === 'name'">
                <span>
                    <smile-outlined />
                    Name
                </span>
            </template>
        </template>
        <!--内容展开-->
        <template #expandedRowRender="{ record }">
            <a-card>
                <a-descriptions title="论文信息" bordered>
                    <a-descriptions-item label="DOI (数字资源标识符)">
                        <a @click="$.copyText(record.doi)">
                            {{ record.doi }}
                            <CopyOutlined></CopyOutlined>
                        </a> </a-descriptions-item>
                    <a-descriptions-item label="署名单位" :span="2"> {{ record.signatureUnit }}</a-descriptions-item>
                    <a-descriptions-item label="期刊名称"> {{ record.journalName }}
                    </a-descriptions-item>
                    <a-descriptions-item label="期刊信息" :span="2">
                        <PaperDict :dictId="record.paperDictId" />
                    </a-descriptions-item>
                    <a-descriptions-item label="论文名称" :span="1">
                        <a @click="$.copyText(record.paperTitle)">
                            {{ record.paperTitle }}
                            <CopyOutlined></CopyOutlined>
                        </a>
                    </a-descriptions-item>
                    <a-descriptions-item label="论文字数" :span="1">{{ record.paperNumber }} (字)</a-descriptions-item>
                    <a-descriptions-item label="负责人字数" :span="1">{{ record.chargeNumber }} (字)</a-descriptions-item>
                    <a-descriptions-item label="发表日期" :span="1">{{ record.publicationDate }}</a-descriptions-item>
                    <a-descriptions-item label="状态" :span="3">
                        <!--执行状态-->
                        <a-tag color="green" v-if="record.status == 1">已通过</a-tag>
                        <a-tag color="red" v-else>已关闭</a-tag>
                    </a-descriptions-item>
                    <a-descriptions-item label="作者信息">

                    </a-descriptions-item>
                </a-descriptions>
            </a-card>

        </template>
        <template #bodyCell="{ column, record }">
            <template v-if="column.key === 'name'">
                <a>
                    {{ record.name }}
                </a>
            </template>
            <template v-else-if="column.key === 'tags'">
                <span>
                    <a-tag v-for="tag in record.tags" :key="tag"
                        :color="tag === 'loser' ? 'volcano' : tag.length > 5 ? 'geekblue' : 'green'">
                        {{ tag.toUpperCase() }}
                    </a-tag>
                </span>
            </template>
            <template v-else-if="column.key === 'action'">
                <!-- <a-button type="link" @click="emit('update',record)">编辑</a-button> -->
                <AntdZh>
                    <a-popconfirm title="确定删除 ?" @confirm="emit('delete', record.id)">
                        <a-button type="link" danger>删除</a-button>
                    </a-popconfirm>
                </AntdZh>
            </template>
            <template v-else-if="column.dataIndex === 'status'">
                <a-tag color="grey" v-if="record.status == 0">未确认</a-tag>
                <a-tag color="green" v-else-if="record.status == 1">已通过</a-tag>
            </template>
        </template>
    </a-table>
</template>
<script setup>
import PaperDict from './PaperDict.vue';
import { SmileOutlined, DownOutlined, CopyOutlined, QuestionCircleOutlined } from '@ant-design/icons-vue';
import userApp from '@/hooks'
const { $ } = userApp()
const emit = defineEmits(['delete', 'update'])
const tips = ref(null)
const props = defineProps({
    data: {
        type: Array,
    }
})

const columns = [
    {
        title: '论文题目',
        dataIndex: 'paperTitle',
        width: '20%'
    },
    {
        title: 'DOI',
        dataIndex: 'doi',
        width: '10%'
    },
    {
        title: '期刊',
        dataIndex: 'journalName',
        width: '13%'
    },
    {
        title: '第一作者',
        dataIndex: 'firstAuthor',
        width: '9%'
    },
    {
        title: '第二作者',
        dataIndex: 'secondAuthor',
        width: '9%'
    },
    {
        title: '状态',
        dataIndex: 'status',
        width: '10%'
    },
    {
        title: '发表时间',
        dataIndex: 'publicationDate',
        width: '10%'
    },
    {
        title: '排序',
        dataIndex: 'orderNum',
    },
    {
        title: '操作',
        key: 'action',
        dataIndex: 'action',
    },
];
</script>
  
  